
var vm = new Vue({
    el: "#serviceVue",
    data: {
        searchs:'',
        loading: true,
        service:[],       //客服
        service_tel:'',
        user_id:'',
        user_name:'',
        city:'',
        web_token:''
    },
    methods: {
        req: function () {
            this.loading = true;
            var url = '/userweb/Homepage/service';
            var data = {
                user_id:    this.user_id,
                city:       this.city
            };
            this.$http.post(url, data, {
                emulateJSON: true
            }).then(function (res) {
                if (res.data.status == 200) {
                    this.service        = res.data.service;
                    this.service_tel    = this.service[0].tel;
                } else {
                    layer.msg("暂无客服",{
                        skin:'winning-class',
                        time:3000
                    });
                }
                /*var _this = this;
                setTimeout(function () {
                    _this.loading = false;
                }, 300);*/
                this.loading = false;
            }, function (res) {

            });

        }
    },
    mounted: function () {
        this.user_id        = localStorage.getItem('user_id');
        this.user_name      = localStorage.getItem('user_name');
        this.city           = localStorage.getItem('city');
        if (!this.city){
            this.city       = 'Devon County';
        }
        this.web_token      = localStorage.getItem('web_token');
        this.req();
        validToken();       //验证tonken.
    }
});
